home *** CD-ROM | disk | FTP | other *** search
/ Delphi 2.0 - Programmer's Utilities Power Pack / Delphi 2.0 Programmer's Utilities Power Pack.iso / s_to_z / ttalker / talker.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  1996-09-15  |  1.6 KB  |  89 lines

  1. unit Talker;
  2.  
  3. interface
  4.  
  5. uses
  6.   SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics, Controls,
  7.   Forms, Dialogs, StdCtrls, FileCtrl;
  8.  
  9. type
  10.   TTalker = class(TComponent)
  11.   private
  12.     FEnabled: boolean;
  13.   protected
  14.   public
  15.     constructor Create(AOwner:TComponent); override;
  16.     Destructor Destroy; override;
  17.     Procedure Talk( AStr: string);
  18.   published
  19.     property Enabled: boolean read FEnabled default False;
  20.   end;
  21.  
  22. var
  23.  DLLHandel: Word;        { for the DLL }
  24.  ISCB:LongInt;
  25.  OpenSpeech: function(WH:hwnd; Mode:word; VoiceType:Pchar):LongInt;
  26.  Say: function(SCB:LongInt;OutStr:Pchar):longInt;
  27.  CloseSpeech: function(SCB:LongInt):LongInt;
  28.  
  29.  
  30. procedure Register;
  31.  
  32.  
  33.  
  34.  
  35.  
  36. implementation
  37.  
  38.  
  39. procedure TTalker.Talk( aStr: string );
  40. var
  41.   nts: PChar;
  42. begin
  43.   nts := StrAlloc(Length(aStr)+1);
  44.   StrPCopy( nts, aStr );
  45.   Say( ISCB, nts );
  46.   StrDispose(nts);
  47. end;
  48.  
  49.  
  50.  
  51. {-- Creates the component and sets the defaults }
  52. constructor TTalker.Create(AOwner: TComponent);
  53. begin
  54.   inherited Create(AOwner);
  55.   FEnabled := False;
  56.   DLLHandel:= LoadLibrary( 'FB_SPCH.DLL' );
  57.   if DLLHandel >= 32 then
  58.    begin
  59.     FEnabled := True;
  60.     @OpenSpeech:= GetProcAddress( DLLHandel, 'OpenSpeech' );
  61.     @Say:= GetProcAddress( DLLHandel, 'Say' );
  62.     @CloseSpeech:= GetProcAddress( DLLHandel, 'CloseSpeech' );
  63.     ISCB:=OpenSpeech(GetActiveWindow,0, nil);
  64.    end;
  65. end;
  66.  
  67.  
  68. Destructor TTalker.Destroy;
  69. Begin
  70.   inherited Destroy;
  71.   closeSpeech(ISCB);
  72.   FreeLibrary( DLLHandel );
  73. End;
  74.  
  75.  
  76.  
  77.  
  78.  
  79.  
  80.  
  81.  
  82.  
  83. procedure Register;
  84. begin
  85.   RegisterComponents('Samples', [TTalker]);
  86. end;
  87.  
  88. end.
  89.